<div class="form_content">
    <div class="f-title">
        是否启用
    </div>
    <div class="f-input">
        <label class="am-radio-inline">
            <input type="radio" name="enable" value="0" data-am-ucheck checked> 启用 </label>
        <label class="am-radio-inline">
            <input type="radio" name="enable" value="1" data-am-ucheck> 禁用</label>
    </div>
    <div class="clear"></div>

    <div class="f-title">
        账号名称
    </div>
    <div class="f-input">
        <input type="text" id="wx_name" class="am-form-field" placeholder="输入账户名称" required/>
    </div>
    <div class="clear"></div>

    <div class="f-title">
        QQ号
    </div>
    <div class="f-input">
        <input type="text" id="account" class="am-form-field" placeholder="输入QQ号" required/>
    </div>
    <div class="clear"></div>

    <div class="f-title">
        最低充值限额
    </div>
    <div class="f-input">
        <input type="text" id="min" class="am-form-field" placeholder="输入最低充值限额，元" required/>
    </div>
    <div class="clear"></div>

    <div class="f-title">
        最高充值限额
    </div>
    <div class="f-input">
        <input type="text" id="max" class="am-form-field" placeholder="输入最高充值限额，元" required/>
    </div>
    <div class="clear"></div>

    <div class="button2">
        <button class="am-btn am-btn-primary btn-save">保存</button>
    </div>
</div>
<script>
    var charges = {};
    GroupUtil.init(false, function() {
        charges = GroupUtil.queryChargeTypes(true);
        var data = charges.cft;
        if (!data) {
            charges.cft = {};
            return;
        }

        // 填入数据
        if (data.enable) $("input:radio[value='0']").prop("checked", "checked");
        else $("input:radio[value='1']").prop("checked", "checked");

        $("#wx_name").val(data.name || '');
        $("#account").val(data.account || '');
        $("#min").val(data.min || 0);
        $("#max").val(data.max || 0);
    });

    $(".btn-save").click(function() {
        startLoading();
        charges.cft.name = $("#wx_name").val().trim();
        charges.cft.account = $("#account").val().trim();
        charges.cft.enable = $("input:radio:checked").val();
        charges.cft.min = $("#min").val();
        charges.cft.max = $("#max").val();
        CMD.modify_group(GroupUtil.group.id, {
            charges: JSON.stringify(charges),
        }, function() {
            stopLoading();
            alert2("保存成功。");
        });
    });
</script>